package com.ddwl.gate.dao;

import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.dao.TkDao;
import com.ddwl.gate.mapper.OperatorConfigMapper;
import com.ddwl.gate.model.OperatorConfig;
import com.ddwl.schema.bo.gate.OperatorConfigPageBo;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author hemiaojun
 * @Date 2020/9/24 9:17
 */
@Repository
public class OperatorConfigDao extends TkDao<OperatorConfigMapper, OperatorConfig> {

    @Resource
    private OperatorConfigMapper operatorConfigMapper;

    public List<OperatorConfig> getList(OperatorConfigPageBo bo) {
        Example example=getExample();
        example.and().andEqualTo("operator", bo.getOperator())
                .andEqualTo("numSegment",bo.getNumSegment());
        return operatorConfigMapper.selectByExample(example);
    }

    public OperatorConfig getByCondition(OperatorConfig entity) {
        entity.setDflag(BaseEnum.DflagEnum.NOT_DELETE.getCode());
        return selectOne(entity);
    }

    public List<OperatorConfig> getAll() {
        Example example = new Example(OperatorConfig.class);
        return operatorConfigMapper.selectByExample(example);
    }

    public void changeId(Map<String, String> map) {
        operatorConfigMapper.changeId(map);
    }
}
